<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
  PUBLIC "-//OASIS//DTD DITA Composite//EN" "ditabase.dtd">
<topic id="topic1">
    <title id="eo20941">START TRANSACTION</title>
    <body>
        <p id="sql_command_desc">Starts a transaction block.</p>
        <section id="section2">
            <title>Synopsis</title>
            <codeblock id="sql_command_synopsis">START TRANSACTION [<varname>transaction_mode</varname>] [READ WRITE | READ ONLY]</codeblock>
            <p>where <varname>transaction_mode</varname> is:</p>
            <codeblock>   ISOLATION LEVEL {SERIALIZABLE | READ COMMITTED | READ UNCOMMITTED}</codeblock>
        </section>
        <section id="section3">
            <title>Description</title>
            <p><codeph>START TRANSACTION</codeph> begins a new transaction block. If the isolation
                level or read/write mode is specified, the new transaction has those
                characteristics, as if <codeph><xref href="SET_TRANSACTION.xml#topic1" type="topic"
                        format="dita"/></codeph> was run. This is the same as the
                    <codeph>BEGIN</codeph> command.</p>
        </section>
        <section id="section4">
            <title>Parameters</title>
            <parml>
                <plentry>
                    <pt>READ UNCOMMITTED</pt>
                    <pt>READ COMMITTED</pt>
                    <pt>REPEATABLE READ</pt>
                    <pt>SERIALIZABLE</pt>
                    <pd>The SQL standard defines four transaction isolation levels: <codeph>READ
                            UNCOMMITTED</codeph>, <codeph>READ COMMITTED</codeph>,
                            <codeph>REPEATABLE READ</codeph>, and
                        <codeph>SERIALIZABLE</codeph>.</pd>
                    <pd><codeph>READ UNCOMMITTED</codeph> allows transactions to see changes made by
                        uncomitted concurrent transactions. This is not possible in Greenplum
                        Database, so <codeph>READ UNCOMMITTED</codeph> is treated the same as
                            <codeph>READ COMMITTED</codeph>.</pd>
                    <pd><codeph>READ COMMITTED</codeph>, the default isolation level in Greenplum
                        Database, guarantees that a statement can only see rows committed before it
                        began. The same statement run twice in a transaction can produce
                        different results if another concurrent transaction commits after the
                        statement is run the first time. </pd>
                    <pd>The <codeph>REPEATABLE READ</codeph> isolation level guarantees that a
                        transaction can only see rows committed before it began. <codeph>REPEATABLE
                            READ</codeph> is the strictest transaction isolation level Greenplum
                        Database supports. Applications that use the <codeph>REPEATABLE
                            READ</codeph> isolation level must be prepared to retry transactions due
                        to serialization failures.</pd>
                    <pd>The <codeph>SERIALIZABLE</codeph> transaction isolation level guarantees
                        that running multiple concurrent transactions produces the same effects as
                        running the same transactions one at a time. If you specify
                            <codeph>SERIALIZABLE</codeph>, Greenplum Database falls back to
                            <codeph>REPEATABLE READ</codeph>.</pd>
                </plentry>
                <plentry>
                    <pt>READ WRITE</pt>
                    <pt>READ ONLY</pt>
                    <pd>Determines whether the transaction is read/write or read-only. Read/write is
                        the default. When a transaction is read-only, the following SQL commands are
                        disallowed: <codeph>INSERT</codeph>, <codeph>UPDATE</codeph>,
                            <codeph>DELETE</codeph>, and <codeph>COPY FROM</codeph> if the table
                        they would write to is not a temporary table; all <codeph>CREATE</codeph>,
                            <codeph>ALTER</codeph>, and <codeph>DROP</codeph> commands;
                            <codeph>GRANT</codeph>, <codeph>REVOKE</codeph>,
                            <codeph>TRUNCATE</codeph>; and <codeph>EXPLAIN ANALYZE</codeph> and
                            <codeph>EXECUTE</codeph> if the command they would run is among
                        those listed.</pd>
                </plentry>
            </parml>
        </section>
        <section id="section5">
            <title>Examples</title>
            <p>To begin a transaction block: </p>
            <codeblock>START TRANSACTION;</codeblock>
        </section>
        <section id="section6">
            <title>Compatibility</title>
            <p>In the standard, it is not necessary to issue <codeph>START TRANSACTION</codeph> to
                start a transaction block: any SQL command implicitly begins a block. Greenplum
                Database behavior can be seen as implicitly issuing a <codeph>COMMIT</codeph> after
                each command that does not follow <codeph>START TRANSACTION</codeph> (or
                    <codeph>BEGIN</codeph>), and it is therefore often called 'autocommit'. Other
                relational database systems may offer an autocommit feature as a convenience. </p>
            <p>The SQL standard requires commas between successive
                    <varname>transaction_modes</varname>, but for historical reasons Greenplum
                Database allows the commas to be omitted.</p>
            <p>See also the compatibility section of <codeph><xref href="SET_TRANSACTION.xml#topic1"
                        type="topic" format="dita"/></codeph>.</p>
        </section>
        <section id="section7">
            <title>See Also</title>
            <p><codeph><xref href="BEGIN.xml#topic1" type="topic" format="dita"/></codeph>,
                        <codeph><xref href="SET_TRANSACTION.xml#topic1" type="topic" format="dita"
                    /></codeph></p>
        </section>
    </body>
</topic>
